package com.headfirst.factory.simplefactory;

import java.util.ArrayList;
import java.util.List;

/**
 * 抽象的Pizza类，具体的Pizza类需要继承这个抽象的Pizza类
 *
 * @author sunhongguang
 * @create 2022-01-23-18:39
 */
public abstract class Pizza {

    /**
     * 名称
     */
    private String name;
    /**
     * 面团类型
     */
    private String dough;
    /**
     * 酱料类型
     */
    private String sauce;
    /**
     * 一套佐料
     */
    List<String> toppings = new ArrayList<>();

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDough() {
        return dough;
    }

    public void setDough(String dough) {
        this.dough = dough;
    }

    public String getSauce() {
        return sauce;
    }

    public void setSauce(String sauce) {
        this.sauce = sauce;
    }

    public List<String> getToppings() {
        return toppings;
    }

    public void setToppings(List<String> toppings) {
        this.toppings = toppings;
    }

    /**
     * 准备
     */
    public void prepare() {
        System.out.println("Preparing " + name);
    }

    /**
     * 烘焙
     */
    public void bake() {
        System.out.println("Baking " + name);
    }

    /**
     * 切割
     */
    public void cut() {
        System.out.println("Cutting " + name);
    }

    /**
     * 装盒
     */
    public void box() {
        System.out.println("Boxing " + name);
    }

    public String toString() {
        StringBuffer display = new StringBuffer();
        display.append("---- " + name + " ----\n");
        display.append(dough + "\n");
        display.append(sauce + "\n");
        for (int i = 0; i < toppings.size(); i++) {
            display.append(toppings.get(i));
            if (i < toppings.size() - 1) {
                display.append(", ");
            }
        }
        return display.toString();
    }
}
